﻿/*******************************************************************************
 * 
 * 
 * 文件名：FormLog.cs
 * 
 * 日  期：2009-05-04
 * 
 * 版  本：1.0.0
 * 
 * Copyright (C) 2009 Gsino
 * 
 * 功  能：日志查询功能
 * 
 * 修改记录
 * 
 * 版本         修改日期            修改人          修改内容
 * 
 * 
 *******************************************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL.TableFunc;
using BLL.Spublic;

namespace 电力热故障系统
{
    public partial class FormLog : Form
    {

        #region 构造函数

        public FormLog()
        {
            InitializeComponent();
            DateTime dt = DateTime.Now.AddDays(-1.0);
            this.StartDatePicker.Value = dt;
            StartTimePicker.Update();
        }

        #endregion

        #region 退出

        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #endregion

        #region 查询

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOK_Click(object sender, EventArgs e)
        {

            OtherFunc of = new OtherFunc();
            //查询时间
            int startTime = of.GetUnixTime(StartDatePicker.Text + " " + StartTimePicker.Text);
            int endTime = of.GetUnixTime(EnddatePicker.Text + " " + EndTimePicker.Text);

            //查询条件
            LogTablesFunc lf = new LogTablesFunc();

            DataSet ds = new DataSet();
            ds = lf.selLog(startTime, endTime);

            DataView dv = ds.Tables[0].DefaultView as DataView;
            dv.AllowNew = false;
            logDataGridView.DataSource = dv;

            logDataGridView.Columns[0].HeaderText = "ID";
            logDataGridView.Columns[1].HeaderText = "操作日志";
            logDataGridView.Columns[2].HeaderText = "操作时间";
            logDataGridView.Columns[0].Width = 70;
            logDataGridView.Columns[2].Width = 150;
            //去掉默认选中状态
            if (logDataGridView.RowCount > 0)
                logDataGridView[0, 0].Selected = false;
            //
            int m_time = 0;
            string systemTime = null;

            for (int i = 0; i < logDataGridView.Rows.Count; i++)
            {
                //转换时间
                m_time = Convert.ToInt32(logDataGridView[2, i].Value);
                systemTime = of.GetSystemTime(m_time);
                logDataGridView[2, i].Value = systemTime;
            }
        }

        #endregion
    }
}